﻿using System;
using System.Collections.Generic;
using System.Text;
using Catalina.Common;
using System.Data;
using System.Collections.ObjectModel;

namespace Catalina.Dal
{
	class CatalinaHeaderReader : SqlReaderBase<CatalinaHeader>
	{
		public CatalinaHeaderReader(String connectionString) : base(connectionString) { }

		protected override string CommandText
		{
			get
			{
				return
					@"SELECT 
						('Catalina ' + CONVERT(varchar, cs.start_date)) AS BatchNo,
						('Catalina batch for ' + CONVERT(varchar, cs.start_date)) AS Description, 
						COUNT(*) AS Printable, 
						0 AS NonPrintable,
						cs.start_date AS StartDate,
						cs.end_date AS EndDate
					FROM
						posplus_catalina_signs cs
					INNER JOIN
						products
					ON cs.upc = products.upc
					GROUP BY cs.Start_Date, cs.End_Date";
			}
		}

		protected override System.Data.CommandType CommandType
		{
			get { return System.Data.CommandType.Text; }
		}

		protected override System.Collections.ObjectModel.Collection<System.Data.IDataParameter> GetParameters(System.Data.IDbCommand command)
		{
			Collection<IDataParameter> param = new Collection<IDataParameter>();

			return param;
		}

		protected override MapperBase<CatalinaHeader> GetMapper()
		{
			return new CatalinaHeaderMapper();
		}
	}
}
